package com.zhang.test_zhang.service.impl;

import com.zhang.test_zhang.entity.Trade;
import com.zhang.test_zhang.mapper.TradeMapper;
import com.zhang.test_zhang.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class TradeServiceImpl implements TradeService {

    @Autowired
    private TradeMapper tradeMapper;

    /**
     * 新增商品
     *
     * @param trade
     * @return
     */
    @Override
    public String addTrade(Trade trade) {

        int id = UUID.randomUUID().toString().replaceAll("-", "").hashCode();
        id = id < 0 ? -id : id;

        trade.setId(id);
        tradeMapper.addTrade(trade);
        return "新增商品成功！";
    }
}
